<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/rp/common/taglib.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <base href="<%=basePath%>">
    
    <title>选择接收人</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	
	<script src="rp/scripts/boot.js" type="text/javascript"></script>
	
	<style type="text/css">
	   	
    </style>
	
  </head>
  
  <body class="body-fit">
  	
  	<div style="width:100%;">
        <div class="mini-toolbar" style="padding:0px;border-top:0;border-left:0;border-right:0;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                   		部门：<input id="organTreeSelect" class="mini-treeselect" 
                   			url="rp/system/organMng/getOrgans" multiSelect="false" valueFromSelect="false"
					        textField="name" valueField="id" parentField="pid" allowInput="false" expandOnLoad="true"
					        onvaluechanged="organTreeChange"/>
					    <a class="mini-button" onclick="showAll();">显示全部</a>
					    <a class="mini-button" onclick="selectAll();">全选</a>
					    <a class="mini-button" onclick="unselectAll();">清除全选</a>
                    </td>
                    <td style="white-space:nowrap;">
                    	
                    </td>
                </tr>
            </table>           
        </div>
    </div>
  	
  	<!-- <div id="userGrid" class="mini-datagrid" 
  		style="width: 100%; height: 100%;" borderStyle="border:0;"
    	url="rp/system/userMng/getUsers" idField="id"  
    	sizeList="[20,30,50,100]" pageSize="100"
    	allowResize="false" multiSelect="true">
	    <div property="columns">
	        <div type="indexcolumn" headerAlign="center">序号</div>
	        <div type="checkcolumn"></div>
	        <div name="realname" field="realname" width="150" headerAlign="center">
	        	姓名
	        </div>
	                       
	    </div>
	</div> -->
	<div class="mini-fit">
		<ul id="userTree" class="mini-tree" url="rp/system/userMng/getAllUsers" 
	        showTreeIcon="false" textField="realname" idField="id" resultAsTree="false"
	        showCheckBox="true" checkRecursive="true" allowSelect="false" enableHotTrack="false">
    	</ul>
	</div>
	
	<div class="mini-toolbar" style="padding: 5px;" borderStyle="border:0;">
        <a class="mini-button" style="width:60px;" onclick="onOk()">确定</a>
        <a class="mini-button" style="width:60px;" onclick="onCancel()">取消</a>
    </div>
  	
	<script type="text/javascript">
		var organTreeSelect;
		var userTree;
		
		$(function(){
			mini.parse();
			organTreeSelect = mini.get("organTreeSelect");
			userTree = mini.get("userTree");
		});
		
		function init(_userIds){
			
		}
		
		function getSelectData(){
			return userTree.getValue();
		}
		
		function getSelectRealname(){
			var realnames = "";
			var nodes = userTree.getCheckedNodes();
			for(var i=0; i<nodes.length; i++){
				realnames = realnames + nodes[i].realname + ","
			}
			return realnames;
		}
		
		function organTreeChange(e){
			userTree.load("rp/system/userMng/getUseraByOrganId?organId="+e.value);
		}
		
		function showAll(){
			organTreeSelect.setValue(null);
			userTree.load("rp/system/userMng/getAllUsers");
		}
		
		function selectAll(){
			var nodes = userTree.getAllChildNodes(userTree.getRootNode());
			userTree.checkNodes(nodes);
		}
		
		function unselectAll(){
			var nodes = userTree.getAllChildNodes(userTree.getRootNode());
			userTree.uncheckNodes(nodes);
		}
		
		//////////////////////////////////
	    function closeWindow(action) {
	        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
	        else window.close();
	    }

	    function onOk() {
	    	closeWindow("ok");
	    }
	    function onCancel() {
	    	closeWindow("cancel");
	    }
	</script>
  </body>
</html>
